/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

/* eslint-disable react/jsx-no-bind */
/**
 * 单号记录、单号使用统计，统一配置
 *  */
import React from 'react';
import { Button } from 'antd';

export default function(sourceType) {
  const orderPageConfig = {
    derivative: {
      actionTypes: {
        record: 'orderRecord/getWsRecordList',
        statistics: 'orderRecord/getWsStatisticsList',
        addDownLoad: 'orderRecord/wsAddDownLoad',
        getDownLoadList: 'orderRecord/wsGetDownloadList',
        statisticsAddDownLoad: 'orderRecord/wsAddDownLoad',
        statisticsGetDownLoadList: 'orderRecord/wsGetDownloadList',
        getDeatil: 'orderRecord/getWsOrderDetail',
      },
      searchBarConfig: {
        site_id: {
          show: false,
        },
        brand: {
          show: false,
        },
        clientCascader: {
          show: true,
          name: 'ws_id',
          placeholder: '请选择微商客户',
        },
        keyword: {
          show: false,
          name: 'keyword',
          placeholder: '可根据微商手机号进行搜索',
        },
        allYz: {
          show: false,
        },
      },
      orderStatisticsColums: [
        {
          title: '日期',
          dataIndex: 'data.time',
          key: 'data.time',
          align: 'center',
        },
        {
          title: '手机号码',
          dataIndex: 'user.username',
          key: 'user.username',
          align: 'center',
        },
        {
          title: '店铺名称',
          dataIndex: 'user.nickname',
          align: 'center',
        },
        {
          title: '单号申报总费用',
          dataIndex: 'data.total_price',
          key: 'data.total_price',
          align: 'center',
        },
        {
          title: '单号数量',
          dataIndex: 'data.num',
          key: 'used_cnt',
          align: 'center',
        },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          align: 'center',
          render: (text, record) => (
            <Button
              type="primary"
              onClick={this.toggleDetail.bind(this, true, record, 'record')} // 查看单号记录
            >
              查看明细
            </Button>
          ),
        },
      ],
      OrderRecordColums: [
        {
          title: '获取单号时间',
          dataIndex: 'data.print_time',
          key: 'data.print_time',
          align: 'center',
        },
        {
          title: '单号',
          dataIndex: 'data.waybill_no',
          key: 'data.waybill_no',
          align: 'center',
          render: (text, record) => (
            <a onClick={this.showExpressModal.bind(this, record)}>{text}</a>
          ),
        },
        {
          title: '快递品牌',
          dataIndex: 'data.brand_name',
          key: 'data.brand',
          align: 'center',
        },
        {
          title: '店铺名称',
          dataIndex: 'user.nickname',
          key: 'user.nickname',
          align: 'center',
        },
        {
          title: '单号价格',
          dataIndex: 'data.price',
          key: 'data.price',
          align: 'center',
        },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          align: 'center',
          render: (text, record) => {
            const { data = {} } = record;
            const { order_no } = data;
            return (
              <Button
                type="primary"
                onClick={this.toggleDetail.bind(this, true, order_no, 'record', data)}
              >
                查看详情
              </Button>
            );
          },
        },
      ],
    },
    operator: {
      actionTypes: {
        record: 'orderRecord/getOrderRecordList',
        statistics: 'orderRecord/getStatisticsList',
        addDownLoad: 'orderRecord/addDownLoadTask',
        getDownLoadList: 'orderRecord/getDownloadTaskList',
        statisticsAddDownLoad: 'orderRecord/addDownLoad',
        statisticsGetDownLoadList: 'orderRecord/getDownloadList',
        getDeatil: 'orderRecord/getOrderRecordDetail',
      },
      searchBarConfig: {
        site_id: {
          show: true,
        },
        brand: {
          show: true,
        },
        clientCascader: {
          show: false,
        },
        keyword: {
          show: true,
          name: 'keyword',
          placeholder: '可根据业务员手机号或者姓名搜索',
        },
        allYz: {
          show: false,
        },
      },
      orderStatisticsColums: [
        {
          title: '日期',
          dataIndex: 'time',
          key: 'time',
          align: 'center',
        },
        {
          title: '站点',
          dataIndex: 'site_name',
          key: 'site_id',
          align: 'center',
        },
        {
          title: '业务员',
          dataIndex: 'courier_name',
          align: 'center',
          render: (text, record) => `${record.courier_name}-${record.courier_phone}`,
        },
        {
          title: '单号收取总费用',
          dataIndex: 'price_cnt',
          key: 'price_cnt',
          align: 'center',
        },
        {
          title: '单号数量',
          dataIndex: 'used_cnt',
          key: 'used_cnt',
          align: 'center',
        },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          align: 'center',
          render: (text, record) => (
            <Button
              type="primary"
              onClick={this.toggleDetail.bind(this, true, record, 'record')} // 查看单号记录
            >
              查看明细
            </Button>
          ),
        },
      ],
      OrderRecordColums: [
        {
          title: '获取单号时间',
          dataIndex: 'apply_at',
          key: 'apply_at',
          align: 'center',
        },
        {
          title: '单号',
          dataIndex: 'waybill_no',
          key: 'waybill_no',
          align: 'center',
          render: (text, record) => (
            <a onClick={this.showExpressModal.bind(this, record)}>{text}</a>
          ),
        },
        {
          title: '快递品牌',
          dataIndex: 'brand_name',
          key: 'brand',
          align: 'center',
        },
        {
          title: '业务员',
          dataIndex: 'courier_info',
          key: 'courier_info',
          align: 'center',
        },
        {
          title: '单号价格',
          dataIndex: 'price',
          key: 'price',
          align: 'center',
        },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          align: 'center',
          render: (text, record) => (
            <Button
              type="primary"
              onClick={this.toggleDetail.bind(this, true, record.id, 'record')}
            >
              查看详情
            </Button>
          ),
        },
      ],
    },
    yz: {
      actionTypes: {
        record: 'orderRecord/getYZRecordList',
        statistics: 'orderRecord/getYZStatisticsList',
        addDownLoad: 'orderRecord/wsAddDownLoad',
        getDownLoadList: 'orderRecord/wsGetDownloadList',
        statisticsAddDownLoad: 'orderRecord/wsAddDownLoad',
        statisticsGetDownLoadList: 'orderRecord/wsGetDownloadList',
        getDeatil: 'orderRecord/getOrderRecordDetail',
      },
      searchBarConfig: {
        site_id: {
          show: false,
        },
        brand: {
          show: false,
        },
        clientCascader: {
          show: false,
        },
        keyword: {
          show: false,
          name: 'keyword',
          placeholder: '可根据业务员手机号或者姓名搜索',
        },
        allYz: {
          show: true,
        },
      },
      orderStatisticsColums: [
        {
          title: '日期',
          dataIndex: 'time',
          key: 'time',
          align: 'center',
          width: 250,
        },
        {
          title: '驿站名称',
          dataIndex: 'cm_name',
          key: 'cm_name',
          align: 'center',
          width: 200,
        },
        {
          title: '联系人',
          dataIndex: 'concat_name',
          align: 'center',
          render: (text, record) => `${record.concat_name}-${record.concat_phone}`,
          width: 250,
        },
        {
          title: '单号收取总费用',
          dataIndex: 'price_cnt',
          key: 'price_cnt',
          align: 'center',
          width: 200,
        },
        {
          title: '单号数量',
          dataIndex: 'used_cnt',
          key: 'used_cnt',
          align: 'center',
          width: 100,
        },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          align: 'center',
          width: 250,
          render: (text, record) => (
            <Button
              type="primary"
              onClick={this.toggleDetail.bind(this, true, record, 'record')} // 查看单号记录
            >
              查看明细
            </Button>
          ),
        },
      ],
      OrderRecordColums: [
        {
          title: '获取单号时间',
          dataIndex: 'apply_at',
          key: 'apply_at',
          align: 'center',
          width: 250,
        },
        {
          title: '单号',
          dataIndex: 'waybill_no',
          key: 'waybill_no',
          align: 'center',
          width: 200,
          render: (text, record) => (
            <a onClick={this.showExpressModal.bind(this, record)}>{text}</a>
          ),
        },
        {
          title: '快递品牌',
          dataIndex: 'brand_name',
          key: 'brand',
          align: 'center',
          width: 200,
        },
        {
          title: '驿站名称',
          dataIndex: 'inn_info',
          key: 'inn_info',
          align: 'center',
          width: 200,
        },
        {
          title: '单号价格',
          dataIndex: 'price',
          key: 'price',
          align: 'center',
          width: 100,
        },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          align: 'center',
          width: 200,
          render: (text, record) => (
            <Button
              type="primary"
              onClick={this.toggleDetail.bind(this, true, record.id, 'record')}
            >
              查看详情
            </Button>
          ),
        },
      ],
    },
  };

  const {
    actionTypes,
    searchBarConfig,
    orderStatisticsColums,
    OrderRecordColums,
  } = orderPageConfig[sourceType];

  return { actionTypes, searchBarConfig, orderStatisticsColums, OrderRecordColums };
}
